home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample PMSAM / PMSAM Framework / Common / CResourceIterator.cp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  1.4 KB  |  64 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CResourceIterator.cp
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Tim Harnett
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <1>    10/25/94    TMH        used is TX25Channel::MakeConnection()
  13.                 10/25/94    TMH        xxx put comment here xxx
  14.  
  15.     To Do:
  16. */
  17.  
  18. #ifndef __CResourceIterator__
  19. #include "CResourceIterator.h"
  20. #endif
  21.  
  22.  
  23. //--------------------------------------------------------------------------------------------------
  24.  CResourceIterator::CResourceIterator(ResType resType,short refNum)
  25. {
  26.     fResType = resType;
  27.     
  28.     fRefNum = refNum;
  29.     if( refNum == 0 )
  30.         fRefNum = CurResFile();
  31.  
  32.  
  33.     short saveRefNum = CurResFile();
  34.     UseResFile(fRefNum);
  35.     fCount = ::Count1Resources(resType);
  36.     UseResFile(saveRefNum);
  37.     
  38.     fIndex = 0;
  39. }
  40.  
  41. //--------------------------------------------------------------------------------------------------
  42. Boolean CResourceIterator::More()
  43. {
  44.     return fIndex <= fCount;
  45. }
  46.  
  47. //--------------------------------------------------------------------------------------------------
  48. Handle  CResourceIterator::FirstResource()
  49. {
  50.     fIndex = 0;
  51.     return (this->More() ? this->NextResource() : 0); 
  52. }
  53.  
  54. //--------------------------------------------------------------------------------------------------
  55. Handle  CResourceIterator::NextResource()
  56. {
  57.     short saveRefNum = CurResFile();
  58.     UseResFile(fRefNum);
  59.     Handle rsrc =  ::Get1IndResource(fResType,++fIndex);
  60.     UseResFile(saveRefNum);
  61.     return rsrc;
  62.  
  63. }
  64.